<template>
    <!-- 公共组件 -->
    <GoodList :list="goodsList"></GoodList>
</template>

<script setup lang="ts">
import { ref, onMounted, type Ref } from 'vue'
import { RequestSearchList } from '@/api/search'
import type { IGoods } from '@/types/types'
import { useSearchStore } from '@/stores/search'
import GoodList from '@/components/GoodList.vue'

const useSearch = useSearchStore()

// 搜索列表
const goodsList: Ref<Array<IGoods>> = ref([])
// 获取搜索列表
const getSearchList = async () => {
    const data = await RequestSearchList(useSearch.searchData)
    const { resultCode, resultInfo } = data
    if (resultCode === 1) {
        goodsList.value = resultInfo.list
    }
}

onMounted(() => {
    getSearchList()
})
</script>

<style lang="scss" scoped>
// 商品列表
.rightcol {
    width: 100%;
    padding-left: 12px; 
    .van-card {
        width: 100%;
        .van-button {
            background-color: rgb(236, 13, 13);
            color: #fff;
            border-radius: 16px;
        }
    }
}
</style>
